//
//  CarBrandSectionView.m
//  DingDongXiChe
//
//  Created by wtjr on 2018/1/11.
//  Copyright © 2018年 xieyingze. All rights reserved.
//

#import "CarBrandSectionView.h"


@interface CarBrandSectionView()

@property (nonatomic, strong) UIView *mainView;

@property (nonatomic, strong) BaseImageView *iconImageView;

@property (nonatomic, strong) BaseLabel *carNameLabel;

@end

@implementation CarBrandSectionView

#pragma mark - Init

- (void)initData {
    
}

- (void)initSubViews {
    [self addSubview:self.mainView];
}

- (void)autoLayoutSubViews {
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@0);
    }];
}

#pragma mark - BaseMethod


#pragma mark - Interface


#pragma mark - Delegate


#pragma mark - TouchEvent

- (void)clickSetionView {
    if (self.clickCompeted) {
        self.clickCompeted(self.section);
    }
}


#pragma mark - Setter

- (void)setViewModel:(CarViewModel *)viewModel {
    _viewModel = viewModel;
    CarBrandModel *model = _viewModel.cars[viewModel.section];
    self.iconImageView.imageName = model.icon;
    self.carNameLabel.text = model.brandName;
}

#pragma mark - Getter

- (UIView *)mainView {
    if (!_mainView) {
        _mainView = [UIView new];
        _mainView.backgroundColor = kCOLOR_tableView;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickSetionView)];
        [_mainView addGestureRecognizer:tap];
        
        BaseImageView *iconImageView = [BaseImageView new];
        iconImageView.layer.cornerRadius = 15;
        iconImageView.layer.masksToBounds = YES;
        iconImageView.imageName = @"aodi";
        self.iconImageView = iconImageView;
        [_mainView addSubview:iconImageView];
        [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@20);
            make.centerY.equalTo(@0);
            make.width.height.equalTo(@30);
        }];
        
        BaseLabel *carNameLabel = [BaseLabel new];
        [carNameLabel setLabelStyle:@"奥迪" textColor:KCOLOR_font_special textFont:kFONT_HelBold(14) texrAlignment:NSTextAlignmentLeft];
        self.carNameLabel = carNameLabel;
        [_mainView addSubview:carNameLabel];
        [carNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(iconImageView.mas_right).offset(5);
            make.centerY.equalTo(@0);
            make.height.equalTo(@20);
        }];
        
        UIView *line = [UIView new];
        line.backgroundColor = kCOLOR_line;
        [_mainView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.equalTo(@0);
            make.height.equalTo(@0.5);
        }];
    }
    return _mainView;
}

@end
